package com.zn.web.callback;

import com.aliyun.oss.OSSClient;
import com.zn.entity.AppCustomer;
import com.zn.entity.CustomerBankInfo;
import com.zn.entity.PayType;
import com.zn.service.AppCustomerService;
import com.zn.service.CustomerBankInfoService;
import com.zn.service.PayChannelService;
import com.zn.service.PayTypeService;
import com.zn.util.DateUtils;
import com.zn.util.EnDecryptUtil;
import com.zn.util.OSSUtil;
import com.zn.vo.Message;
import com.zn.vo.PayMethodVo;
import com.zn.vo.Response;
import com.zn.web.dto.CustomerWithdrawDto;
import com.zn.web.dto.OnLineRechargeDto;
import com.zn.web.dto.PayChannelDto;
import com.zn.web.dto.UnderLineRechargeDto;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/payCallback")
public class PayCallback {
    private static final Logger LOGGER = LoggerFactory.getLogger(PayCallback.class);
    @Autowired
    private PayChannelService payChannelService;

    /**
     * 线上充值结果异步回调
     * @return
     */
    @RequestMapping(value = "/onLineRechargeCallback",method = RequestMethod.POST)
    public String onLineRechargeCallback(@RequestBody Response response) {
        try {
            LOGGER.info("onLineRechargeCallback .... " + response.toString());
            payChannelService.onLineRechargeCallback(response);
            return "SUCCESS";
        }catch (Exception e){
            LOGGER.error("onLineRechargeCallback......",e);
            return "ERROR";
        }
    }

    /**
     * 线上充值提交成功异步回调
     * @return
     */
    @RequestMapping(value = "/submitSuccessCallback",method = RequestMethod.POST)
    public String submitSuccessCallback(@RequestBody Response response) {
        try {
            LOGGER.info("submitSuccessCallback .... " + response.toString());
            payChannelService.submitSuccessCallback(response);
            return "SUCCESS";
        }catch (Exception e){
            LOGGER.error("submitSuccessCallback......",e);
            return "ERROR";
        }
    }

    /**
     * 代付结果查询
     * @return
     */
    @RequestMapping(value = "/dfQueryByCustomer",method = RequestMethod.POST)
    public void dfQueryByCustomer(@RequestParam("customerId") String customerId) {
        try {
            LOGGER.info("dfQueryByCustomer .... " + customerId);
            payChannelService.dfQueryByCustomer(customerId);
        }catch (Exception e){
            e.printStackTrace();
        }
    }



}